// N1Exception.h: interface for the N1Exception class.
//
//////////////////////////////////////////////////////////////////////

#ifndef N1EXCEPTION_H__
#define N1EXCEPTION_H__

#include "N1String.h"

#define N1ThrowException(msg) \
   N1Exception::Throw(msg " (%s:%u)", __FILE__, __LINE__); 

#define N1ThrowException1(msg, p1) \
   N1Exception::Throw(msg " (%s:%u)", p1, __FILE__, __LINE__); 

#define N1ThrowException2(msg, p1, p2) \
   N1Exception::Throw(msg " (%s:%u)", p1, p2, __FILE__, __LINE__); 

#define N1ThrowException3(msg, p1, p2, p3) \
   N1Exception::Throw(msg " (%s:%u)", p1, p2, p3, __FILE__, __LINE__); 

template<class Exception>
void ThrowException(const char* Format, ...)
{
   va_list marker;
   va_start( marker, Format);

   N1AnsiString *str = new N1AnsiString();
   str->formatv(Format, marker);

   throw Exception(str);
   va_end( marker );
}

class N1Exception {
protected:
    N1AnsiString *m_str;

	N1Exception();
public:
	N1Exception(N1AnsiString *msg);
	virtual ~N1Exception();

	N1AnsiString* getMessage();

    static void Throw(const char* Format, ...);
};

#endif // N1EXCEPTION_H__
